package com.bitcola.exchange.push.rest;

import cn.hutool.http.HttpUtil;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RequestMapping("DingDing")
@RestController
public class DingDingPush {
    public static String url="https://oapi.dingtalk.com/robot/send?access_token=4999c41cbe30d92fda188807edfa25a993f5d4b1dccdd84c5216803dd7e2ff27";

    static String temp=" {\"msgtype\": \"text\", \n" +
            "       \"text\": {\n" +
            "            \"content\": \"通知:%s\"\n" +
            "        }\n" +
            "     }";

    @RequestMapping(value = "push",method = RequestMethod.POST)
    boolean push(@RequestBody Map<String,String> content){
        var contentStr=content.get("content");



        String result=String.format(temp,contentStr);
        var response=  HttpUtil.createPost(url).header("Content-Type","application/json").body(result).execute();
        return true;

    }


    public static void main(String []s){


//        new DingDingPush().push("测试推送");



    }


}
